import { createPinia, defineStore } from 'pinia';

const useUserStore = defineStore('user', {
    state: () => ({
        token: localStorage.getItem('token') || '',
        userInfo: null,
    }),
    actions: {
        setToken(token) {
            this.token = token;
            localStorage.setItem('token', token);
        },
        clearToken() {
            this.token = '';
            localStorage.removeItem('token');
        },
        // 其他actions
    },
});

const pinia = createPinia();

export { pinia, useUserStore };